package cn.ecut;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class InsertUpdateDelete {
    public static void main(String[] args) throws Exception{
        Class.forName("com.mysql.cj.jdbc.Driver") ;
        String url = "jdbc:mysql://localhost:3306/ecut?serverTimezone=Asia/Shanghai" ;
        String username = "root" ;
        String password = "root" ;
        Connection connection = DriverManager.getConnection(url , username , password ) ;
        Statement statement = connection.createStatement() ;

        // 插入 删除 修改
        String insert_sql = "insert into country( countryname, countrycode) values ('Japan','rb') " ;
        String update_sql = "update country set countrycode='rbrb' where countryname='Japan'" ;
        String delete_sql = "delete from country where countrycode='mg' " ;

        int executeUpdate = statement.executeUpdate(insert_sql);
        System.out.println( executeUpdate );
        executeUpdate = statement.executeUpdate(update_sql);
        System.out.println( executeUpdate );
        executeUpdate = statement.executeUpdate(delete_sql);
        System.out.println( executeUpdate );

        statement.close();
        connection.close();
    }
}
